<?php

class Visits_Bootstrap extends Engine_Application_Bootstrap_Abstract
{
  public function __construct($application)
  {
    parent::__construct($application);
    $this->initViewHelperPath();
    
    // Get settings
    $settings = Engine_Api::_()->getApi('settings', 'core');
    $notifications_check = $settings->getSetting('visits.notifications', 1);
    
    // Get viewer
    $viewer = Engine_Api::_()->user()->getViewer();
    
    // check permissions
    if($viewer->getIdentity()) {
        if($notifications_check && Engine_Api::_()->authorization()->isAllowed('visits', $viewer, 'view')) {
            $headScript = new Zend_View_Helper_HeadScript();
            $headScript->appendFile('application/modules/Visits/externals/scripts/core.js');
        }
    }
  }
}